import { handlers } from "./handlers.js";
import { isObject } from "./utils.js";
const targetMap = new WeakMap()
export function reactive(target) {
    // 1.非对象，返回
    if (!isObject(target)) return target
    // 2.缓存有值，返回对应值
    if (targetMap.has(target)) {
        return targetMap.get(target)
    }
    // 3.创建代理
    const proxy = new Proxy(target, handlers)
    targetMap.set(target, proxy)
    return proxy;
}